package com.example.gulimall.order.web;


import com.alipay.api.AlipayApiException;
import com.example.gulimall.order.config.AlipayTemplate;
import com.example.gulimall.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PayWebController {

    @Autowired private AlipayTemplate alipayTemplate;
    @Autowired private OrderService orderService;

    @ResponseBody
    @GetMapping(value = "/payOrder", produces = "text/html")
    public String pryOrder (@RequestParam("orderSn") String orderSn) throws AlipayApiException {
        return this.alipayTemplate.pay(this.orderService.getPay(orderSn));
    }

}
